package com.leonzhangxf.aop.program;

import com.leonzhangxf.aop.bean.HelloWorldService;
import com.leonzhangxf.aop.bean.impl.HelloWorldServiceImpl;
import org.springframework.aop.framework.ProxyFactory;

/**
 * 单独的编程式生成代理
 *
 * @author leonzhangxf
 * @date 20190529
 */
public class ProgramApplication {

    public static void main(String[] args) {
        HelloWorldServiceImpl helloWorldService = new HelloWorldServiceImpl();
        ProxyFactory proxyFactory = new ProxyFactory(helloWorldService);

        proxyFactory.addAdvice(new CustomMethodInterceptor());
        proxyFactory.addAdvisor(new CustomAdvisor());

        HelloWorldService service = (HelloWorldService) proxyFactory.getProxy();
        service.helloWorld();
    }
}
